<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<style>
    .active{
        color: red;
    }
</style>
<body>
    <div id="app">
        <ul>
            <!-- 循环数组，绑定样式 -->
            <li v-for="(item, index) in movies"
            :class="{active:currentIndex === index}"
            @click="liClick(index)">
            {{index+1}}.{{ item }}
        </li>
        </ul>
    </div>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                movies: ['金刚', "海贼王", "蝙蝠侠", "阿凡达"],
                currentIndex: 0 //用变量记录状态
            },
            methods:{
                liClick(index) {
                    this.currentIndex = index
                }
            }
        })
    </script>
</body>
</html>